package com.gs.wzweather.dao;

import com.gs.wzweather.dao.mapper.SurHorMapper;
import com.gs.wzweather.entity.Site;
import com.gs.wzweather.utils.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class SurHorDao {

    Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    SurHorMapper mapper;

    public List<Site> queryMax(String beginTime, String endTime, String element) {
        try {
            List<Site> sites = mapper.queryMax(beginTime, endTime, element);
            return sites;
        } catch (Exception e) {
            logger.info("queryMax->{}", e.getMessage());
            return null;
        }
    }

    public String queryMaxByStation(String station,String beginTime,String endTime,String element){
        try {
            return mapper.queryMaxByStation(station,beginTime,endTime,element);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    public List<Site> queryMin(String beginTime, String endTime, String element) {
        try {
            List<Site> sites = mapper.queryMin(beginTime, endTime, element);
            return sites;
        } catch (Exception e) {
            logger.info("queryMin->{}", e.getMessage());
            return null;
        }
    }

    public List<Site> queryAvg(String beginTime, String endTime, String element) {
        try {
            List<Site> sites = mapper.queryAvg(beginTime, endTime, element);
            return sites;
        } catch (Exception e) {
            logger.info("queryAvg->{}", e.getMessage());
            return null;
        }
    }
}
